package com.carrental.common.exception;

import com.carrental.common.response.ResultCode;
import lombok.Getter;

/**
 * 操作异常
 *
 * @author 梁毅
 */
@Getter
public class OperationException extends RuntimeException {
    private final Long code;
    private final String message;

    public OperationException(Long code, String message) {
        this.code = code;
        this.message = message;
    }

    public OperationException(String message) {
        this.code = 5000L;
        this.message = message;
    }

    public OperationException() {
        this.code = 5000L;
        this.message = "操作失败！";
    }

    public OperationException(ResultCode resultStatusEnum) {
        this.code = resultStatusEnum.getCode();
        this.message = resultStatusEnum.getMessage();
    }

    public OperationException(ResultCode resultStatusEnum, String additional) {
        this.code = resultStatusEnum.getCode();
        this.message = resultStatusEnum.getMessage() + additional;
    }
}
